package com.byxy.computer.student.service;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.byxy.computer.student.entity.LessonMaterial;
import com.byxy.computer.student.utils.MaterialData;

@Repository
public class LessonMaterialDao {

	public List<LessonMaterial> findAll() {
		return MaterialData.lists;
	}

	public LessonMaterial save(LessonMaterial lm) {
		MaterialData.lists.add(lm);
		return lm;
	}

	public void deleteById(String id) {
		for (LessonMaterial l : MaterialData.lists) {
			if (l.getId().equals(id)) {
				MaterialData.lists.remove(l);
				return;
			}
		}
	}

	public LessonMaterial findById(String id) {
		for (LessonMaterial l : MaterialData.lists) {
			if (l.getId().equals(id)) {
				return l;
			}
		}
		return null;
	}
}
